package com.example.demo4activemq

import org.springframework.jms.annotation.JmsListener
import org.springframework.stereotype.Component

import java.util.concurrent.atomic.AtomicInteger

@Component
class Receiver {

    static final AtomicInteger counter = new AtomicInteger(0)

    @JmsListener(destination = "demo.mailbox", containerFactory = "myFactory")
    void receiveMessage(Email email) {
        println "[${counter.incrementAndGet()}] Received <$email>"
    }

    @JmsListener(destination = "demo.map", containerFactory = "myFactory")
    void receiveMessage(Map msg) {
        println msg
    }
}
